package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.response.ProjectTaskMemberResponse;
import com.nbsaas.boot.project.data.entity.ProjectTaskMember;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
/**
 * 任务参与人-实体对象转化成响应对象
 */

public class ProjectTaskMemberResponseConvert implements Converter<ProjectTaskMemberResponse, ProjectTaskMember> {

    @Override
    public ProjectTaskMemberResponse convert(ProjectTaskMember source) {
        ProjectTaskMemberResponse result = new ProjectTaskMemberResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getTask() != null) {
            result.setTask(source.getTask().getId());
        }
        if (source.getMemberType() != null) {
            result.setMemberTypeName(String.valueOf(source.getMemberType()));
        }
        if (source.getUser() != null) {
            result.setUser(source.getUser().getId());
        }
        return result;
    }

}

